package com.yurun.service.impl;

import com.yurun.entity.OperationLog;
import com.yurun.exception.PersistenceException;
import com.yurun.mapper.OperationLogMapper;
import com.yurun.service.OperationLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OperationLogServiceImpl implements OperationLogService {
    @Autowired
    OperationLogMapper operationLogMapper;

    @Override
    public void addOperationLog(OperationLog log){
        if(operationLogMapper.addOperationLog(log)!=1){
            throw new PersistenceException("添加操作日志失败");
        }
    }

    @Override
    public void deleteOperationLogById(Long id){
        if(operationLogMapper.deleteOperationLogById(id)!=1){
            throw new PersistenceException("删除操作日志失败");
        }
    }

    @Override
    public List<OperationLog> getOperationLogListByDate(String startDate,String endDate){
        return operationLogMapper.getOperationLogListByDate(startDate, endDate);
    }
}
